package main


import(
    "fmt"
    "strings"
    "strconv"
)

func solution(n int, k int, s string) string {
    l := strings.Split(s, "");
    var cnt int = 0

    var res string

    num, err := strconv.ParseInt(s, 10, 64) // 10表示十进制，64表示使用int64类型（如果需要的话）
    if err != nil {
        fmt.Println("转换错误:", err)
        return ""
    }

    for cnt < k {

        if len(s) == 1 || num == 0 {
            break
        }
        for i:=0; i< len(l)-1; i++ {
            if l[i] == "0" && l[i+1] == "1" {
                continue
            } else if l[i] == "0" && l[i+1] == "0" {
                continue
            } else if l[i] == "1" && l[i+1] == "1" {
                continue
            } else {
                l[i], l[i+1] = l[i+1], l[i]
                cnt++
                break
            }
        }
        new_str := strings.Join(l, "")
        res = new_str
        new_int, err := strconv.Atoi(new_str)
        if err != nil {
            fmt.Println("转换错误:", err)
            return ""
        }
        new_str_1 := strconv.Itoa(new_int)

        if len(new_str_1) == strings.Count(s, "1") {
            break
        }
    }

    return res
}


func main(){
    fmt.Println(solution(5, 2, "01010") == "00101")
    fmt.Println(solution(7, 3, "1101001") == "0110101")
    fmt.Println(solution(4, 1, "1001") == "0101")
}
